package com.gu.mapper;

import com.gu.entity.ApartmentDO;
import java.util.List;

import com.gu.resultMap.ApartmentWithUserMap;
import org.apache.ibatis.annotations.Param;

/**
 * 由于需要对分页支持,请直接使用对应的DAO类
 * The Table gu_apartment.
 * 公寓表
 */
public interface ApartmentMapper{

    /**
     * desc:插入表:gu_apartment.<br/>
     * descSql =  SELECT LAST_INSERT_ID() <![CDATA[ INSERT INTO gu_apartment( ID ,ROOM_NUMBER ,USER_ID ,UNIT_NUMBER ,FLOOR_NUMBERR ,BUILDING_NUMBER ,CREATE_TIME ,UPDATE_TIME )VALUES( null , #{roomNumber,jdbcType=VARCHAR} , #{userId,jdbcType=INTEGER} , #{unitNumber,jdbcType=INTEGER} , #{floorNumberr,jdbcType=INTEGER} , #{buildingNumber,jdbcType=INTEGER} , #{createTime,jdbcType=DATE} , #{updateTime,jdbcType=DATE} ) ]]>
     * @param entity entity
     * @return Integer
     */
    Integer insert(ApartmentDO entity);
    /**
     * desc:批量插入表:gu_apartment.<br/>
     * descSql =  INSERT INTO gu_apartment( ID ,ROOM_NUMBER ,USER_ID ,UNIT_NUMBER ,FLOOR_NUMBERR ,BUILDING_NUMBER ,CREATE_TIME ,UPDATE_TIME )VALUES ( null , #{item.roomNumber,jdbcType=VARCHAR} , #{item.userId,jdbcType=INTEGER} , #{item.unitNumber,jdbcType=INTEGER} , #{item.floorNumberr,jdbcType=INTEGER} , #{item.buildingNumber,jdbcType=INTEGER} , #{item.createTime,jdbcType=DATE} , #{item.updateTime,jdbcType=DATE} ) 
     * @param list list
     * @return Integer
     */
    Integer insertBatch(List<ApartmentDO> list);
    /**
     * desc:根据主键删除数据:gu_apartment.<br/>
     * descSql =  <![CDATA[ DELETE FROM gu_apartment WHERE ID = #{id,jdbcType=INTEGER} ]]>
     * @param id id
     * @return Integer
     */
    Integer deleteById(Integer id);
    /**
     * desc:根据主键获取数据:gu_apartment.<br/>
     * descSql =  SELECT * FROM gu_apartment WHERE <![CDATA[ ID = #{id,jdbcType=INTEGER} ]]>
     * @param id id
     * @return ApartmentDO
     */
    ApartmentDO getById(Integer id);

    /**
     * 查找未入住的房间
     * @param entity
     * @return
     */
    List<String> getNotUsedApartmentRoomNumber(ApartmentDO entity);

    /**
     * 查找已入住的房间
     * @param entity
     * @return
     */
    List<String> getUsedApartmentRoomNumber(ApartmentDO entity);

    List<ApartmentWithUserMap> listApartment(ApartmentDO apartmentDO);

    int updateApartment(@Param("userId") Integer userId,@Param("id") Integer id);

    int updateApartmentUserId(@Param("userId") Integer userId,@Param("id") Integer id);

    List<ApartmentDO> getAllApartment();

    List<ApartmentDO> getApartmentByUser (Integer userId);
}
